package com.jsh.erp.controller;

import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.retailRecord.RetailRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Map;

@RestController
@RequestMapping(value = "/retailRecord")
@Api(tags = {"单据管理"})
public class RetailRecordController {

    @Resource
    private RetailRecordService retailRecordService;

    @PostMapping(value = "/record")
    @ApiOperation(value = "交班信息")
    public Map record(HttpServletRequest request)throws Exception {
        return retailRecordService.getByIdWithStartTime(request);
    }

    @PostMapping(value = "/getCashboxChangeRecord")
    @ApiOperation(value = "修改钱箱金额修改记录")
    public Map getCashboxChangeRecord(@RequestBody JSONObject jsonObject,HttpServletRequest request)throws Exception {
        return retailRecordService.getCashboxChangeRecord(jsonObject,request);
    }

    @PostMapping(value = "/changeCashbox")
    @ApiOperation(value = "修改钱箱金额")
    public Map changeCashbox(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception {
        return retailRecordService.changeCashbox(jsonObject,request);
    }

    @PostMapping(value = "/submitWork")
    @ApiOperation(value = "交班并退出")
    public Map submitWork(HttpServletRequest request)throws Exception {
        return retailRecordService.submitWork(request);
    }

    @PostMapping(value = "/initCashBox")
    @ApiOperation(value = "初始化钱箱金额")
    public Map initCashBox(@RequestBody JSONObject jsonObject,  HttpServletRequest request)throws Exception {
        return retailRecordService.initCashBox(jsonObject,request);
    }
}
